﻿<?xml version="1.0" encoding="UTF-8"?>
<!--
Xslt file for translating android resources into Xaml.  
I used msxsl.exe to do the translate and added the Xaml directly to the project. 
The ideal would be to use a custom build step.  But there are only so many days in a life.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
                xmlns:clr="clr-namespace:System;assembly=mscorlib"
                xmlns:sr="clr-namespace:Subsonic.Resources;assembly=Subsonic"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <xsl:output method="html" 
              indent="yes"
              omit-xml-declaration = "yes"
              />

  <xsl:template match="/resources">
    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
      <xsl:apply-templates select="string"/>
      <xsl:apply-templates select="plurals"/>
    </ResourceDictionary>
  </xsl:template>

  <xsl:template match="string">
    <xsl:element name="clr:String">
      <xsl:attribute name="x:Key">
        <xsl:value-of select="substring-before(@name,'.')"/>_<xsl:value-of select="substring-after(@name,'.')"/>
      </xsl:attribute>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match="plurals">
    <xsl:element name="sr:Plural">
      <xsl:attribute name="x:Key">
        <xsl:value-of select="@name"/>
      </xsl:attribute>
      <xsl:apply-templates select="item[@quantity='zero']"/>
      <xsl:apply-templates select="item[@quantity='one']"/>
      <xsl:apply-templates select="item[@quantity='other']"/>
    </xsl:element>
  </xsl:template>

  <xsl:template match="item[@quantity='zero']">
    <xsl:attribute name="Zero">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>

  <xsl:template match="item[@quantity='one']">
    <xsl:attribute name="One">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>
  
  <xsl:template match="item[@quantity='other']">
    <xsl:attribute name="Other">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>

</xsl:stylesheet>
